const { ref, onMounted } = Vue

export function usePageHeightSet() {
  const uncheckTaskHeight = ref(window.innerHeight - 584);// 【待检任务】区域高度
  const tableHeight = ref(window.innerHeight - 405);// 待检明细表格高度

  function setHeight(height) {
    if (height < 100) {
      uncheckTaskHeight.value = window.innerHeight - 584;
      tableHeight.value = window.innerHeight - 405;
    } else {
      uncheckTaskHeight.value = window.innerHeight - 583;
      tableHeight.value = window.innerHeight - 469;
    }
  }

  onMounted(() => {
    window.addEventListener('resize', () => {
      const h = document.getElementById('btn-wrapper').clientHeight;
      if (h < 100) {
        uncheckTaskHeight.value = window.innerHeight - 584;
        tableHeight.value = window.innerHeight - 405;
      } else {
        uncheckTaskHeight.value = window.innerHeight - 583;
        tableHeight.value = window.innerHeight - 469;
      }
    });
  });

  return { uncheckTaskHeight, tableHeight, setHeight }
}